'''利用两个栈实现队列的功能'''
class MyQueue(object):
    def __init__(self):
        self.inStack = [] #输入栈
        self.outStack = [] #输出栈

    def push(self,x):
        self.inStack.append(x)

    def pop(self):
        if self.empty():
            return None
        if self.outStack:
            return self.outStack.pop()
        else:
            for i in range(len(self.inStack)):
                self.outStack.append(self.inStack.pop())
            return self.outStack.pop()

    def peek(self):
        if not self.outStack:
            while self.inStack:
                self.outStack.append(self.inStack.pop())
        return self.outStack[-1]

    def empty(self):
        return not self.inStack and not self.outStack
def main():
    myqueue=MyQueue()
    myqueue.push("a")
    myqueue.push("b")
    param_2 = myqueue.pop()
    param_3 = myqueue.peek()
    param_4 = myqueue.empty()
    print(param_2,param_3,param_4)
if __name__ == '__main__':
    main()


